﻿@model PrestoDashboardWeb.Models.EntityContainer
<!DOCTYPE html>
<html lang="en">
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link href="~/Content/jquery.mobile-1.3.2.min.css" rel="stylesheet" />    
    <script src="~/Scripts/jquery-1.8.2.min.js"></script>
    <script src="~/Scripts/jquery.mobile-1.3.2.min.js"></script>
    <title>Presto</title>
    
    </head>

    <body>
      
        <div data-role="header" data-theme="a">
            <img src="~/Content/images/wizard1.ico" height="48" width="48" style="display: block; float: right;"/>
            <h1 style="font-size: 32px">Presto</h1>
        </div>

        <div data-role="navbar" data-grid="d">
            <ul>
                <li onclick="showApps()"><a href="#" class="ui-btn-active">Apps</a></li>
                <li onclick="showServers()"><a href="#">Servers</a></li>
                <li onclick="showVariableGroups()"><a href="#">Variables</a></li>
                <li><a href="#">Resolve</a></li>
                <li onclick="showInstalls()"><a href="#">Installs</a></li>
                <li><a href="#">Log</a></li>
                <li><a href="#">Ping</a></li>
                <li><a href="#">Global</a></li>
                <li><a href="#">Security</a></li>
            </ul>
        </div><!-- /navbar -->
      
        <div data-role="header" data-theme="b">
            <a href="#" onclick="moveBack()" data-icon="back" style="display: block; float: left;">Back</a>
            <h1 id="selectedTab"><span>Apps</span></h1>
        </div>

        <div id="appList">
            @Html.Partial("~/Views/PartialViews/AppList.cshtml", Model.Applications)
        </div>
      
        <div id="serverList">
            @Html.Partial("~/Views/PartialViews/ServerList.cshtml", Model.Servers)
        </div>
        
        <div id="variableGroupList">
            @Html.Partial("~/Views/PartialViews/VariableGroupList.cshtml", Model.VariableGroups)
        </div>
        
        <div id="installsList">
            @Html.Partial("~/Views/PartialViews/InstallsList.cshtml", Model.InstallationSummaries)
        </div>
        
        <div id="app">
            @Html.Partial("~/Views/PartialViews/App.cshtml")
        </div>
        
        <div id="server">
            @Html.Partial("~/Views/PartialViews/Server.cshtml")
        </div>
        
        <div id="task0">
            @Html.Partial("~/Views/PartialViews/TaskCopyFile.cshtml")
        </div>

        <div id="task1">
            @Html.Partial("~/Views/PartialViews/TaskDosCommand.cshtml")
        </div>
        
        <div id="task2">
            @Html.Partial("~/Views/PartialViews/TaskXmlModify.cshtml")
        </div>
        
        <div id="task3">
            @Html.Partial("~/Views/PartialViews/TaskVersionChecker.cshtml")
        </div>
        
        <div data-role="footer" data-position="fixed">
            <h1 id="footerText">Presto!</h1>
        </div>
    </body>    
    
    <script>
        var stack = [];

        $(function () {
            showApps();
        });

        function moveBack() {
            var divName = stack.pop();
            if (divName) {
                hideAll();
                $('#' + divName).show();
            }
        }

        function showApps() {
            hideAll();
            $('#appList').show();
            $('#selectedTab').text('Apps');
        }

        function showServers() {
            hideAll();
            $('#serverList').show();
            $('#selectedTab').text('Servers');
        }

        function showVariableGroups() {
            hideAll();
            $('#variableGroupList').show();
            $('#selectedTab').text('Variable Groups');
        }

        function showInstalls() {
            hideAll();
            $('#installsList').show();
            $('#selectedTab').text('Installations');
        }

        function hideAll() {
            $('#appList').hide();
            $('#serverList').hide();
            $('#variableGroupList').hide();
            $('#app').hide();
            $('#server').hide();
            $('#task0').hide();
            $('#task1').hide();
            $('#task2').hide();
            $('#task3').hide();
            $('#installsList').hide();
        }

        function showApp(id) {
            hideAll();
            $('#app').show();            
            window.appInitialize(id);
            stack.push('appList');  // What goes here is the div we want to display when the user hits the back button.
        }

        function showServer(id) {
            hideAll();
            $('#server').show();
            window.serverInitialize(id);
            stack.push('serverList');  // What goes here is the div we want to display when the user hits the back button.
        }

        function showTask(app, task) {
            hideAll();

            stack.push('app');

            var taskDiv = $('#task' + task.PrestoTaskType);
            if (taskDiv[0]) {
                taskDiv.show();
                window.taskInitialize(app, task);
                return;
            }

            alert('No task view available for task type ' + task.PrestoTaskType);
        }
    </script>    
</html>